package demo2;

public class LeetCode11 {
    public int maxArea(int[] height) {
        int n = height.length;
        int left = 0, right = n - 1;
        int sum = 0;
        while(left < right) {
            int tmp = Math.min(height[left], height[right]) * (right - left);
            sum = Math.max(sum, tmp);
            if (height[left] < height[right]) left++;
            else right--;
        }
        return sum;
    }
}
